home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 4.3 KB | 212 lines | [TEXT/MSET] |
- \ 28Oct94 dbh updated to 2.5 syntax
-
- (*
-
- The ListManager class is intended for subclassing. See class list-col for
- an example.
-
- *)
-
- \ dataBounds and Cell are a couple of special classes for Lists
-
- :class dataBounds super{ object }
- record{
- longword junk \ not used??
- int #rows
- int #cols
- }
-
- :m put#rows: ( n -- )
- put: #rows ;m
-
- :m put#cols: ( n -- )
- put: #cols ;m
-
- :m get#rows: ( -- n )
- get: #rows ;m
-
- :m get#cols: ( -- n )
- get: #cols ;m
-
- :m put: ( #rows #cols -- )
- put#cols: self put#rows: self ;m
-
- ;class
-
-
- :class cell super{ object }
- record{
- int row#
- int col#
- }
-
- :m getrow#: ( -- n )
- get: row# ;m
-
- :m getcol#: ( -- n )
- get: col# ;m
-
- :m putrow#: ( n -- )
- put: row# ;m
-
- :m putcol#: ( n -- )
- put: col# ;m
-
- :m put: ( row# col# -- )
- putcol#: self putrow#: self ;m
-
- :m cell: ( row# col# -- cell ) \ leaves the cell's contents, as a point, on the stack
- put: self
- addr: self @ ;m
-
- ;class
-
-
- :class ListManager super{ nullSelect font }
- handle ListHandle
- ptr thewptr
- bool scrollHoriz
- bool scrollVert
- dataBounds theBounds \ for LNew call
- rect+ rView \ for LNew call
- var MaxDataLen \ maximum byte length for the text in a cell
- handle dataBuf \ temporary storage needed by LGetCell call
- int dataLen \ temporary storage needed by LGetCell call
- cell theCell \ temporary storage needed by LGetSelect call
- x-addr dbl-click
-
- :m setwidth: ( w -- ) \ pixels
- setwidth: rView ;m
-
- :m setheight: ( h -- ) \ pipxels
- setheight: rView ;m
-
- :m move: ( dx dy -- ) \ only use before new:
- move: rView ;m
-
- :m moveto: ( x y -- ) \ only use before new:
- moveto: rView ;m
-
- :m #rows: ( -- n )
- ptr: ListHandle 72 ( offset to dataBounds in record) +
- get#rows: dataBounds ;m
-
- :m #cols: ( -- n )
- ptr: ListHandle 72 ( offset to dataBounds in record) +
- get#cols: dataBounds ;m
-
- :m hit?: \ ( -- b )
- where: theMouse
- get: rview put: temprect
-
- get: scrollVert
- IF 16 0 stretch: temprect THEN \ stretch width to include the vertical scroll
-
- get: scrollHoriz
- IF 0 16 stretch: temprect THEN \ stretch width to include the horizontal scroll
-
- temprect PtinRect ;m
-
-
- :m new: { wptr -- }
- getnew: super> font
- wptr put: thewptr
- 0 \ space for handle returned from LNew call
- rView
- theBounds
- 0 \ cSize, use default cell sizes
- word0 \ theProc, use default
- wptr
- true tbool \ drawit
- false tbool \ hasgrow
- get: scrollHoriz tbool
- get: scrollVert tbool
- call LNew
- put: ListHandle
- get: MaxDataLen new: dataBuf ;m
-
- private
- :m LGetSelect: { row# col# next -- b } \ raw toolbox call
- row# col# put: theCell \ set up theCell for toolbox call
- word0 \ room for result
- next tbool
- theCell
- get: ListHandle call LGetSelect i->l ;m
-
- :m LSetSelect: { row# col# setIt -- }
- setIt tbool
- row# col# cell: theCell
- get: ListHandle call LSetSelect ;m
-
- :m LActivate: ( flag -- )
- tbool get: ListHandle call LActivate ;m
- public
-
- :m activate:
- true LActivate: self ;m
-
- :m deactivate:
- false LActivate: self ;m
-
- :m release:
- release: dataBuf
- get: ListHandle call LDispose ;m
-
- :m draw:
- set: super> font
- \ first do a normal LUpdate
- get: thewptr 24 + @ ( visRgn ) get: ListHandle call LUpdate
- \ then draw a rectangle around the cells
- get: rview put: temprect
- -1 -1 inset: temprect
- call PenNormal
- draw: temprect ;m
-
- :m show: \ will autoscroll to the currently selected cell
- get: ListHandle call LAutoScroll ;m
-
- :m select: ( row# col# -- )
- true LSetSelect: self ;m
-
- :m deselect: ( row# col# -- )
- false LSetSelect: self ;m
-
- :m click:
- set: super> font
- word0 \ room for result
- where: theMouse pack \ pt
- mods: fevent makeint \ modifiers
- get: ListHandle call LClick
- ( -- b ) \ true if double-click in same cell
- i->l IF exec: dbl-click THEN ;m
-
- :m dblclick: ( cfa -- )
- put: dbl-click ;m
-
- :m at: { row# col# -- addr len }
- ptr: dataBuf \ dataPtr = dest addr
- get: MaxDataLen put: dataLen dataLen \ VAR dataLen = requested length
- row# col# cell: theCell
- get: ListHandle call LGetCell
- ptr: dataBuf get: dataLen ;m \ will return len = actual length
-
- :m to: { addr len row# col# -- }
- addr \ dataPtr
- len get: MaxDataLen min makeint \ dataLen
- row# col# cell: theCell
- get: ListHandle call LSetCell ;m
-
- :m DoDraw: { flag -- }
- flag tbool get: ListHandle call LDoDraw
- flag IF clear: rview update: rview THEN \ only if turning drawing back on
- ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- The ListManager class is intended for subclassing. See class list-col for
- an example.
-